import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyHome(),
  ));
}

class MyHome extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.red,
          title: Text('案例-商品订单信息'),
        ),
        // ListView.builder 批量生成
        // ListView.separated 额外的设置分隔的内容
        body: GridView(
            // 设置宽度
            gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
                // 要设置个数
                // gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                // 侧轴方向子元素的个数
                // crossAxisCount: 2,Ò
                maxCrossAxisExtent: 100,
                mainAxisSpacing: 10,
                crossAxisSpacing: 30,
                childAspectRatio: 4 / 3),
            children: [
              Container(
                color: Colors.green,
                alignment: Alignment.center,
                child: const Text('黑马程序员1'),
              ),
              // 帮我生成 20 个 不同颜色的 Container
              for (var i = 0; i < 20; i++)
                Container(
                  color: Colors.primaries[i % Colors.primaries.length],
                  alignment: Alignment.center,
                  child: const Text('黑马程序员'),
                )
            ]));
  }
}
